{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Reformat Date"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: reformatDate"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #转变日期格式"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个字符串&nbsp;<code>date</code>&nbsp;，它的格式为&nbsp;<code>Day Month Year</code>&nbsp;，其中：</p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>Day</code>&nbsp;是集合&nbsp;<code>{&quot;1st&quot;, &quot;2nd&quot;, &quot;3rd&quot;, &quot;4th&quot;, ..., &quot;30th&quot;, &quot;31st&quot;}</code>&nbsp;中的一个元素。</li>\n",
    "\t<li><code>Month</code>&nbsp;是集合&nbsp;<code>{&quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;, &quot;Jul&quot;, &quot;Aug&quot;, &quot;Sep&quot;, &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot;}</code>&nbsp;中的一个元素。</li>\n",
    "\t<li><code>Year</code>&nbsp;的范围在 ​<code>[1900, 2100]</code>&nbsp;之间。</li>\n",
    "</ul>\n",
    "\n",
    "<p>请你将字符串转变为&nbsp;<code>YYYY-MM-DD</code>&nbsp;的格式，其中：</p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>YYYY</code>&nbsp;表示 4 位的年份。</li>\n",
    "\t<li><code>MM</code>&nbsp;表示 2 位的月份。</li>\n",
    "\t<li><code>DD</code>&nbsp;表示 2 位的天数。</li>\n",
    "</ul>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>date = &quot;20th Oct 2052&quot;\n",
    "<strong>输出：</strong>&quot;2052-10-20&quot;\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>date = &quot;6th Jun 1933&quot;\n",
    "<strong>输出：</strong>&quot;1933-06-06&quot;\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>date = &quot;26th May 1960&quot;\n",
    "<strong>输出：</strong>&quot;1960-05-26&quot;\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li>给定日期保证是合法的，所以不需要处理异常输入。</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [reformat-date](https://leetcode.cn/problems/reformat-date/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [reformat-date](https://leetcode.cn/problems/reformat-date/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['\"20th Oct 2052\"', '\"6th Jun 1933\"', '\"26th May 1960\"']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        month_names: List[str] = [\n",
    "            \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n",
    "            \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\",\n",
    "        ]\n",
    "        month_number: Dict[str, int] = {\n",
    "            m: c for m, c in zip(month_names, range(1, 13))\n",
    "        }\n",
    "\n",
    "        day, month, year = date.split()\n",
    "        year = int(year)\n",
    "        month = month_number[month]\n",
    "        day = int(day[:-2])\n",
    "        \n",
    "        return \"{:04d}-{:02d}-{:02d}\".format(year, month, day)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        datelist = date.split(\" \")\n",
    "        year = str(datelist[2])\n",
    "        month = datelist[1]\n",
    "        day = datelist[0]\n",
    "        m1 = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        new_month=m1.index(month)+1\n",
    "        if new_month<10:\n",
    "            new_month = \"0\"+str(new_month)\n",
    "        else:\n",
    "            new_month = str(new_month)\n",
    "        new_day = day[:-2]\n",
    "        if len(new_day)==1:\n",
    "            new_day=\"0\"+new_day\n",
    "        return year+\"-\"+new_month+\"-\"+new_day   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day,month,year=date.split()\n",
    "        dic={\"Jan\":1, \"Feb\":2, \"Mar\":3, \"Apr\":4, \"May\":5, \"Jun\":6, \"Jul\":7, \"Aug\":8, \"Sep\":9, \"Oct\":10, \"Nov\":11, \"Dec\":12}\n",
    "        return \"%s-%02d-%02d\" %(year,dic[month],int(day[:-2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        map = {\"Jan\": \"1\", \"Feb\": \"2\", \"Mar\":\"3\", \"Apr\": \"4\", \"May\": \"5\",\n",
    "               \"Jun\": \"6\", \"Jul\": \"7\", \"Aug\": \"8\", \"Sep\": \"9\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"}\n",
    "        date = date.split(' ')\n",
    "        date.reverse()\n",
    "        date[2] = date[2][:-2].rjust(2, '0')\n",
    "        date[1] = map[date[1]].rjust(2, '0')\n",
    "        return '-'.join(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day, month, year = date.split(\" \")\n",
    "        dic={'Jan':'01',\"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\", \"May\":\"05\", \"Jun\":\"06\",\n",
    "         \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "        day = day[:-2]\n",
    "        if len(day) == 1:\n",
    "            day=\"0\"+day\n",
    "        return \"-\".join([year, dic[month],day])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date = date.split(' ')\n",
    "        if len(date[0]) == 3:\n",
    "            day = date[0][0]\n",
    "            day = '0' + str(day)\n",
    "        else:\n",
    "            day = date[0][0:2]\n",
    "        months = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12'}\n",
    "        mon = months[date[1]]\n",
    "        year = date[2]\n",
    "        return '-'.join([year, mon, day])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date_li = date.split()\n",
    "        months_set = [\"\",\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        days_set = [\"\", \"1st\", \"2nd\", \"3rd\", \"4th\", \"5th\", \"6th\", \"7th\", \"8th\", \"9th\", \"10th\", \"11th\", \"12th\", \"13th\", \"14th\", \"15th\", \"16th\", \"17th\", \"18th\", \"19th\", \"20th\", \"21st\", \"22nd\", \"23rd\", \"24th\", \"25th\", \"26th\", \"27th\", \"28th\", \"29th\", \"30th\", \"31st\"]\n",
    "        year, month, day = date_li[-1], months_set.index(date_li[1]), days_set.index(date_li[0])\n",
    "        # day = '0' + day if len(day)==1 else day\n",
    "        # month = '0' + month if len(month)==1 else month\n",
    "        # return year + '-' + month + '-' + day\n",
    "        return \"%s-%02d-%02d\" % (year, month, day)\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day,mon,year=date.split()\n",
    "        mon_lst = [\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"]\n",
    "        mon_map={mon:idx for idx,mon in enumerate(mon_lst,1)}\n",
    "        return \"%s-%02d-%02d\" % (year,mon_map[mon],int(day[:-2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        li = date.split()  # 分割字符串\n",
    "        day = li[0][:-2] if len(li[0][:-2]) > 1 else '0' + li[0][:-2]  # 得到day\n",
    "        dic = {\"Jan\":1, \"Feb\":2, \"Mar\":3, \"Apr\":4, \"May\":5, \"Jun\":6, \"Jul\":7, \"Aug\":8, \"Sep\":9, \"Oct\":10, \"Nov\":11, \"Dec\":12}\n",
    "        month = str(dic[li[1]]) if len(str(dic[li[1]])) > 1 else '0' + str(dic[li[1]]) # 得到month\n",
    "        return li[2] + '-' + month + '-' + day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "MONTH = [0,\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date = date.split()\n",
    "        day = date[0][:-2]\n",
    "        month = MONTH.index(date[1])\n",
    "        year = date[2]\n",
    "        return f'{year}-{month:02}-{day:>02}'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        Month = {\n",
    "            \"Jan\":'01', \n",
    "            \"Feb\":'02', \n",
    "            \"Mar\":'03', \n",
    "            \"Apr\":'04', \n",
    "            \"May\":'05', \n",
    "            \"Jun\":'06', \n",
    "            \"Jul\":'07', \n",
    "            \"Aug\":'08', \n",
    "            \"Sep\":'09', \n",
    "            \"Oct\":'10', \n",
    "            \"Nov\":'11', \n",
    "            \"Dec\":'12'\n",
    "        }\n",
    "        res = date.split(' ')[-1] + '-' + Month[date.split(' ')[1]] + '-'\n",
    "        res += date.split(' ')[0][:-2] if len(date.split(' ')[0]) > 3 else ('0' + date.split(' ')[0][:-2])\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        dic = {\"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"}\n",
    "        date=date.split(\" \")\n",
    "        print(date)\n",
    "        ans=[0]*3\n",
    "        ans[2]=date[0][:-2].zfill(2)\n",
    "        ans[1]=dic.get(date[1])\n",
    "        ans[0]=date[2]\n",
    "        print(ans)\n",
    "        return \"-\".join(ans)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        ddate=date.split()\n",
    "        mmon={\"Jan\":'01', \"Feb\":'02', \"Mar\":'03', \"Apr\":'04', \"May\":'05', \"Jun\":'06', \"Jul\":'07', \"Aug\":'08', \"Sep\":'09', \"Oct\":'10', \"Nov\":'11', \"Dec\":'12'}\n",
    "        t=[x for x in ddate[0] if x.isdigit() ]        \n",
    "        ddate[0]='{:02d}'.format(int(''.join(t)))\n",
    "        ddate[1]=mmon[ddate[1]]\n",
    "        #print(ddate)\n",
    "        return ddate[2]+'-'+ddate[1]+'-'+ddate[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date = date.split(' ')\n",
    "        months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        year = date[2]\n",
    "        month = months.index(date[1])+1\n",
    "        if len(date[0])==3:\n",
    "            day = int(date[0][0])\n",
    "        else:\n",
    "            day = int(date[0][:2])\n",
    "        out = str(year) + '-' + str(month).zfill(2) + '-' + str(day).zfill(2)\n",
    "        return out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        ls = date.split(' ')[::-1]\n",
    "        m = {\"Jan\":'01', \"Feb\":'02', \"Mar\":'03', \"Apr\":'04', \"May\":'05', \"Jun\":'06', \n",
    "             \"Jul\":'07', \"Aug\":'08', \"Sep\":'09', \"Oct\":'10', \"Nov\":'11', \"Dec\":'12'}\n",
    "        if len(ls[2]) == 3:\n",
    "            ls[2] = '0'+ls[2]\n",
    "        return ls[0] + '-' + m[ls[1]] + '-' + ls[2][:-2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"\n",
    "        }\n",
    "        \n",
    "        date = date.split(\" \")\n",
    "        \n",
    "        date[0] = date[0][: -2].zfill(2)\n",
    "        date[1] = s2month.get(date[1])\n",
    "        date.reverse()\n",
    "        \n",
    "        return \"-\".join(date)\n",
    "\n",
    "# 作者：力扣官方题解\n",
    "# 链接：https://leetcode.cn/problems/reformat-date/solutions/336420/zhuan-bian-ri-qi-ge-shi-by-leetcode-solution/\n",
    "# 来源：力扣（LeetCode）\n",
    "# 著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        dic = {\"Jan\": '01', \"Feb\": '02', \"Mar\": '03', \"Apr\": '04', \"May\": '05', \"Jun\": '06', \"Jul\": '07', \"Aug\": '08', \"Sep\": '09', \"Oct\": '10', \"Nov\": '11', \"Dec\": '12'}\n",
    "        year = date[-4:]\n",
    "        month = date[-8: -5]\n",
    "        day = date[: -11]\n",
    "        if len(day) == 1:\n",
    "            day = '0' + day\n",
    "        res = year + '-' + dic[month] + '-' + day\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        year = date[len(date)-4:len(date):1]\n",
    "        dic={\"Jan\":'01',\"Feb\":'02',\"Mar\":'03',\"Apr\":'04',\"May\":'05',\"Jun\":'06',\"Jul\":'07',\"Aug\":'08',\"Sep\":'09',\"Oct\":10,\"Nov\":'11',\"Dec\":'12'}\n",
    "        month = dic[date[len(date)-8:len(date)-5:1]]\n",
    "        if len(date)==13:\n",
    "            day = date[0:2:1]\n",
    "        else:\n",
    "           date = '0' + date[0]\n",
    "           day = date[0:2:1]\n",
    "        return year+\"-\"+str(month)+\"-\"+day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date = date.split(' ')\n",
    "        day = \"\"\n",
    "        for ch in date[0]:\n",
    "            if ch.isalpha():break\n",
    "            else:day += ch\n",
    "        if len(day)==1:dd = '0'+day\n",
    "        else:dd = day\n",
    "        month = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        mon = date[1]\n",
    "        if len(str(month.index(mon)+1))==1:mm = '0'+str(month.index(mon)+1)\n",
    "        else:mm = str(month.index(mon)+1)\n",
    "        year = date[2]\n",
    "        return year+'-'+mm+'-'+dd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        dic = {\"Jan\":\"01\", \"Feb\":\"02\",\"Mar\":\"03\",\"Apr\":\"04\",\"May\":\"05\",\"Jun\":\"06\",\"Jul\":\"07\",\"Aug\":\"08\",\"Sep\":\"09\",\"Oct\":\"10\",\"Nov\":\"11\",\"Dec\":\"12\"}\n",
    "        year = date[-4:]\n",
    "        month = dic[date[-8:-5]]\n",
    "        day = date[:-11]\n",
    "        if len(day) == 1:\n",
    "            day = \"0\"+day\n",
    "        return year+\"-\"+month+\"-\"+day\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "import re\n",
    "from datetime import datetime\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        segs = re.search(r'(\\d{1,2}).*?(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec).*?(\\d{4})', date, flags=re.I).groups()\n",
    "        day, month, year = segs\n",
    "        month = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"].index(month) + 1\n",
    "        return datetime(int(year), month, int(day)).strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        d=date.split(' ')\n",
    "        a={'Jan':'01','Feb':'02','Mar':'03','Apr':'04','May':'05','Jun':'06','Jul':'07','Aug':'08','Sep':'09','Oct':'10','Nov':'11','Dec':'12'}\n",
    "        s=''\n",
    "        for i in d[0]:\n",
    "            if i.isdigit():\n",
    "                s+=i\n",
    "        if len(s)==1:\n",
    "            s='0'+s\n",
    "        return d[-1]+'-'+a[d[1]]+'-'+s\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        ans = date.split(\" \")\n",
    "        \n",
    "        Month={\n",
    "            \"Jan\": \"01\",\n",
    "            \"Feb\": \"02\",\n",
    "            \"Mar\": \"03\",\n",
    "            \"Apr\":\"04\",\n",
    "            \"May\":\"05\",\n",
    "            \"Jun\":\"06\",\n",
    "            \"Jul\":\"07\",\n",
    "            \"Aug\":\"08\",\n",
    "            \"Sep\":\"09\",\n",
    "            \"Oct\":\"10\",\n",
    "            \"Nov\":\"11\",\n",
    "            \"Dec\":\"12\"\n",
    "        }\n",
    "        ans[2] = ans[2] + \"-\"+Month[ans[1]]\n",
    "        if len(ans[0]) == 3:\n",
    "            ans[2] = ans[2] + \"-0\"+ans[0][0:1]\n",
    "        else:\n",
    "            ans[2] = ans[2] + \"-\"+ans[0][0:2]\n",
    "        return ans[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "\n",
    "        date = date.split(' ')\n",
    "\n",
    "        monthDict = dict(zip([\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"],[str(i) if i >= 10 else '0' + str(i) for i in range(1,13,1)]))\n",
    " \n",
    "        return date[2] + '-' + monthDict[date[1]] + '-' + ('' if len(date[0][ : -2]) == 2 else '0') + date[0][ : -2] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        d,m,y=date.split()\n",
    "        mon_lst = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        return '%s-%02d-%02d'%(y,mon_lst.index(m)+1,int(d[:-2]))\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day,month,year = date.split()\n",
    "        months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        mon_map = {mon:idx for idx,mon in enumerate(months,1)}\n",
    "        # return \"{}-{:0>2d}-{:0>2d}\".format(year,mon_map[month], int(day[:-2]))\n",
    "        return \"%s-%02d-%02d\" % (year, mon_map[month], int(day[:-2]))\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        a = date.split(\" \")\n",
    "        ms = {\"Jan\":1, \"Feb\":2, \"Mar\":3, \"Apr\":4, \"May\":5, \"Jun\":6, \"Jul\":7, \"Aug\":8, \"Sep\":9, \"Oct\":10, \"Nov\":11, \"Dec\":12}\n",
    "        year = a[2]\n",
    "        m = ms[a[1]]\n",
    "        if m < 10:\n",
    "            m = \"0\" + str(m)\n",
    "        t = 0 \n",
    "        for c in a[0]:\n",
    "            if c.isdigit():\n",
    "                t = t * 10 + ord(c) - ord('0')\n",
    "        if t < 10:\n",
    "            t = \"0\" + str(t)\n",
    "\n",
    "        return f'{year}-{m}-{t}'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date):\n",
    "        mon = {\"Jan\": '01', \"Feb\": '02', \"Mar\": '03', \"Apr\": '04', \"May\": '05', \"Jun\": '06',\n",
    "               \"Jul\": '07', \"Aug\": '08', \"Sep\": '09', \"Oct\": '10', \"Nov\": '11', \"Dec\": '12'}\n",
    "        date_list = date.split(' ')\n",
    "        date = ''\n",
    "        for word in date_list[0]:\n",
    "            if 48 <= ord(word) <= 57:\n",
    "                date += word\n",
    "        if len(date) == 1:\n",
    "            date = '0' + date\n",
    "        res = date_list[2]+'-'+mon[date_list[1]]+'-'+date\n",
    "        return res\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day,month,year = date.split()\n",
    "        months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        # return \"{}-{:0>2d}-{:0>2d}\".format(year,months.index(month)+1, int(day[:-2]))\n",
    "        return \"%s-%02d-%02d\" % (year, months.index(month)+1, int(day[:-2]))\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        Month = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        res = \"\"\n",
    "        YYYY = date[-4:]\n",
    "        if len(date) == 13:\n",
    "            MM = Month.index(date[5:8])+1\n",
    "            DD = date[0:2]\n",
    "        else:\n",
    "            MM = Month.index(date[4:7])+1\n",
    "            DD = date[0:1]\n",
    "        if MM < 10:\n",
    "            MM = \"0\"+str(MM)\n",
    "        else:\n",
    "            MM = str(MM)\n",
    "        if int(DD) < 10:\n",
    "            DD = \"0\" + str(DD)\n",
    "        return YYYY + \"-\" + MM + \"-\" + DD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        year = date[len(date)-4:len(date):1]\n",
    "        dic={\"Jan\":'01',\"Feb\":'02',\"Mar\":'03',\"Apr\":'04',\"May\":'05',\"Jun\":'06',\"Jul\":'07',\"Aug\":'08',\"Sep\":'09',\"Oct\":10,\"Nov\":'11',\"Dec\":'12'}\n",
    "        month = dic[date[len(date)-8:len(date)-5:1]]\n",
    "        if len(date)==13:\n",
    "            day = date[0:2:1]\n",
    "        else:\n",
    "           date = '0' + date[0]\n",
    "           day = date[0:2:1]\n",
    "        return year+\"-\"+str(month)+\"-\"+day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        month_dict = {\n",
    "            \"Jan\" : \"01\", \n",
    "            \"Feb\" : \"02\", \n",
    "            \"Mar\" : \"03\", \n",
    "            \"Apr\" : \"04\", \n",
    "            \"May\" : \"05\", \n",
    "            \"Jun\" : \"06\", \n",
    "            \"Jul\" : \"07\", \n",
    "            \"Aug\" : \"08\", \n",
    "            \"Sep\" : \"09\", \n",
    "            \"Oct\" : \"10\", \n",
    "            \"Nov\" : \"11\", \n",
    "            \"Dec\" : \"12\"}\n",
    "        data = date.split(\" \")\n",
    "        day = data[0][:len(data[0]) - 2]\n",
    "        if len(day) == 1:\n",
    "            day = \"0\" + day\n",
    "        month = data[1]\n",
    "        year = data[2]\n",
    "        return year+\"-\"+month_dict[month]+\"-\"+day\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        lst = date.split(\" \")\n",
    "        res = \"\"\n",
    "        dic_month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"}\n",
    "        lst[0] = lst[0][:-2].zfill(2)\n",
    "        lst[1] = dic_month.get(lst[1])\n",
    "        return \"-\".join(lst[::-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\",\n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"\n",
    "        }\n",
    "\n",
    "        data = date.split()\n",
    "        data[0] = data[0][:-2].zfill(2)\n",
    "        data[1] = s2month[data[1]]\n",
    "        data.reverse()\n",
    "        return '-'.join(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\",\n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"}\n",
    "        lst = date.split(\" \")\n",
    "        ans = \"%s-%s-%02d\" % (lst[2], month[lst[1]], int(lst[0][:-2]))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        year = date[len(date)-4:len(date):1]\n",
    "        dic={\"Jan\":'01',\"Feb\":'02',\"Mar\":'03',\"Apr\":'04',\"May\":'05',\"Jun\":'06',\"Jul\":'07',\"Aug\":'08',\"Sep\":'09',\"Oct\":10,\"Nov\":'11',\"Dec\":'12'}\n",
    "        month = dic[date[len(date)-8:len(date)-5:1]]\n",
    "        if len(date)==13:\n",
    "            day = date[0:2:1]\n",
    "        else:\n",
    "           date = '0' + date[0]\n",
    "           day = date[0:2:1]\n",
    "        return year+\"-\"+str(month)+\"-\"+day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        m={\"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\", \"May\":\"05\", \"Jun\":\"06\", \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "        date=date.split()\n",
    "        res=[]\n",
    "        res.append(date[2])\n",
    "        res.append(m[date[1]])\n",
    "        if len(date[0])==3:\n",
    "            res.append(\"0\"+date[0][0])\n",
    "        else:\n",
    "            res.append(date[0][:2])\n",
    "\n",
    "        return \"-\".join(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"\n",
    "        }\n",
    "        \n",
    "        date = date.split(\" \")\n",
    "        \n",
    "        date[0] = date[0][: -2].zfill(2)\n",
    "        date[1] = s2month.get(date[1])\n",
    "        date.reverse()\n",
    "        \n",
    "        return \"-\".join(date)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        month = {\"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\", \"May\":\"05\", \"Jun\":\"06\", \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "        x = \"\"\n",
    "        for i in range (len(date)):\n",
    "            if date[i].isdigit():\n",
    "                x += date[i]\n",
    "            else:\n",
    "                break\n",
    "        if len(x) == 1:\n",
    "            x = \"0\" + x\n",
    "        return date[-4:] + \"-\" + month[date[-8:-5]] + \"-\" + x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"\n",
    "        }\n",
    "        \n",
    "        date = date.split(\" \")\n",
    "        \n",
    "        date[0] = date[0][: -2].zfill(2)\n",
    "        date[1] = s2month.get(date[1])\n",
    "        date.reverse()\n",
    "        \n",
    "        return \"-\".join(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        ddate=date.split()\n",
    "        mmon={\"Jan\":'01', \"Feb\":'02', \"Mar\":'03', \"Apr\":'04', \"May\":'05', \"Jun\":'06', \"Jul\":'07', \"Aug\":'08', \"Sep\":'09', \"Oct\":'10', \"Nov\":'11', \"Dec\":'12'}\n",
    "        t=[x for x in ddate[0] if x.isdigit() ]        \n",
    "        ddate[0]='{:02d}'.format(int(''.join(t)))\n",
    "        ddate[1]=mmon[ddate[1]]\n",
    "        print(ddate)\n",
    "        return ddate[2]+'-'+ddate[1]+'-'+ddate[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day,month, year = date.split(\" \")\n",
    "        month_dict = {\"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\", \"May\":\"05\", \"Jun\":\"06\", \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "        day_str = day[:-2]\n",
    "        if len(day_str) == 1:\n",
    "            day_str = \"0\"+day_str\n",
    "        return f\"{year}-{month_dict.get(month)}-{day_str}\"\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\", \"May\":\"05\",         \"Jun\":\"06\", \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\",\"Dec\":\"12\"\n",
    "        }\n",
    "        date = date.split(\" \")\n",
    "        date[0] = date[0][:-2].zfill(2)\n",
    "# 在Python中，zfill函数是一个用于字符串操作的内置函数。它用于在字符串的左侧填充指定数量的零（zero），使字符串达到指定的长度。\n",
    "#1.2 zfill函数的语法\n",
    "#str.zfill(width)\n",
    "#其中，str表示需要进行填充的字符串，width表示最终字符串的总长度。\n",
    "        date[1] = s2month.get(date[1])\n",
    "        date.reverse()\n",
    "        return \"-\".join(date)\n",
    "  \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date):\n",
    "        mon = {\"Jan\": '01', \"Feb\": '02', \"Mar\": '03', \"Apr\": '04', \"May\": '05', \"Jun\": '06',\n",
    "               \"Jul\": '07', \"Aug\": '08', \"Sep\": '09', \"Oct\": '10', \"Nov\": '11', \"Dec\": '12'}\n",
    "        date_list = date.split(' ')\n",
    "        date = date_list[0][:-2]\n",
    "        if len(date) == 1:\n",
    "            date = '0' + date\n",
    "        res = date_list[2]+'-'+mon[date_list[1]]+'-'+date\n",
    "        return res\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day, mon, year = date.split()\n",
    "        mon_lst = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        mon_map = {mon:idx for idx,mon in enumerate(mon_lst,1)}\n",
    "        return \"%s-%02d-%02d\" % (year, mon_map[mon], int(day[:-2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        ans = date.split(\" \")\n",
    "        \n",
    "        Month={\n",
    "            \"Jan\": \"01\",\n",
    "            \"Feb\": \"02\",\n",
    "            \"Mar\": \"03\",\n",
    "            \"Apr\":\"04\",\n",
    "            \"May\":\"05\",\n",
    "            \"Jun\":\"06\",\n",
    "            \"Jul\":\"07\",\n",
    "            \"Aug\":\"08\",\n",
    "            \"Sep\":\"09\",\n",
    "            \"Oct\":\"10\",\n",
    "            \"Nov\":\"11\",\n",
    "            \"Dec\":\"12\"\n",
    "        }\n",
    "        ans[2] = ans[2] + \"-\"+Month[ans[1]]\n",
    "        if len(ans[0]) == 3:\n",
    "            ans[2] = ans[2] + \"-0\"+ans[0][0:1]\n",
    "        else:\n",
    "            ans[2] = ans[2] + \"-\"+ans[0][0:2]\n",
    "        return ans[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date_li = date.split()\n",
    "        months_set = [\"\",\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        days_set = [\"\", \"1st\", \"2nd\", \"3rd\", \"4th\", \"5th\", \"6th\", \"7th\", \"8th\", \"9th\", \"10th\", \"11th\", \"12th\", \"13th\", \"14th\", \"15th\", \"16th\", \"17th\", \"18th\", \"19th\", \"20th\", \"21st\", \"22nd\", \"23rd\", \"24th\", \"25th\", \"26th\", \"27th\", \"28th\", \"29th\", \"30th\", \"31st\"]\n",
    "        year, month, day = date_li[-1], str(months_set.index(date_li[1])), str(days_set.index(date_li[0]))\n",
    "        day = '0' + day if len(day)==1 else day\n",
    "        month = '0' + month if len(month)==1 else month\n",
    "        return year + '-' + month + '-' + day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"\n",
    "        }\n",
    "        \n",
    "        date = date.split(\" \")\n",
    "        \n",
    "        date[0] = date[0][: -2].zfill(2)\n",
    "        date[1] = s2month.get(date[1])\n",
    "        date.reverse()\n",
    "        \n",
    "        return \"-\".join(date)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        month_map = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        day, month, year = date.split(' ')\n",
    "        day = day[:-2]\n",
    "        if len(day) < 2:\n",
    "            day = '0' + day\n",
    "        month = str(month_map.index(month) + 1)\n",
    "        if len(month) < 2:\n",
    "            month = '0' + month\n",
    "        return year + '-' + month + '-' + day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        ans=''\n",
    "        date=date.split()\n",
    "        ans+=str(date[2])\n",
    "        ans+='-'\n",
    "        month=['',\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        m=month.index(date[1])\n",
    "        if m<10:\n",
    "            ans+='0'+str(m)+'-'\n",
    "        else:\n",
    "            ans+=str(m)+'-'\n",
    "        if len(date[0])==3:\n",
    "            ans+='0'+date[0][0]\n",
    "        else:\n",
    "            ans+=date[0][:2]\n",
    "        return ans\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        month = {\"Jan\": \"01\",\n",
    "                 \"Feb\": \"02\",\n",
    "                 \"Mar\": \"03\",\n",
    "                 \"Apr\": \"04\",\n",
    "                 \"May\": \"05\", \n",
    "                 \"Jun\": \"06\",\n",
    "                 \"Jul\": \"07\", \n",
    "                 \"Aug\": \"08\", \n",
    "                 \"Sep\": \"09\", \n",
    "                 \"Oct\": \"10\", \n",
    "                 \"Nov\": \"11\", \n",
    "                 \"Dec\": \"12\"\n",
    "                 }\n",
    "        parse = date.split(\" \")\n",
    "        ans = parse[2]+\"-\"+month[parse[1]]+\"-\"\n",
    "        if len(parse[0]) == 3:\n",
    "            ans += \"0\"+parse[0][0]\n",
    "        else:\n",
    "            ans += parse[0][0:2]\n",
    "        return ans         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"\n",
    "        }\n",
    "        \n",
    "        date = date.split(\" \")\n",
    "        \n",
    "        date[0] = date[0][:-2].zfill(2)\n",
    "        date[1] = s2month.get(date[1])\n",
    "        date.reverse()\n",
    "        \n",
    "        return \"-\".join(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        s2month = {\n",
    "            \"Jan\": \"01\", \"Feb\": \"02\", \"Mar\": \"03\", \"Apr\": \"04\", \"May\": \"05\", \"Jun\": \"06\", \n",
    "            \"Jul\": \"07\", \"Aug\": \"08\", \"Sep\": \"09\", \"Oct\": \"10\", \"Nov\": \"11\", \"Dec\": \"12\"\n",
    "        }\n",
    "        \n",
    "        date = date.split(\" \")\n",
    "        \n",
    "        date[0] = date[0][: -2].zfill(2)\n",
    "        date[1] = s2month.get(date[1])\n",
    "        date.reverse()\n",
    "        \n",
    "        return \"-\".join(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        months={\"Jan\":'01',\"Feb\":'02',\"Mar\":'03',\"Apr\":'04',\"May\":'05',\"Jun\":'06',\"Jul\":'07',\"Aug\":'08',\"Sep\":'09',\"Oct\":'10', \"Nov\":'11', \"Dec\":'12'}\n",
    "        time=date.split()\n",
    "        if len(time[0])==3:\n",
    "            time[0]='0'+time[0]\n",
    "        return time[-1]+'-'+months[time[-2]]+'-'+time[0][0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from datetime import datetime\n",
    "import re\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        return datetime.strptime(re.sub('st|nd|rd|th', '', date), '%d %b %Y').strftime(\"%Y-%m-%d\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        d = {\"Jan\":'01', \"Feb\":'02', \"Mar\":'03', \"Apr\":'04', \"May\":'05', \"Jun\":'06', \"Jul\":'07', \"Aug\":'08', \"Sep\":'09', \"Oct\":'10', \"Nov\":'11', \"Dec\":'12'}\n",
    "        date = date.split()\n",
    "        ans = [date[-1]]\n",
    "        ans.append(d[date[-2]])\n",
    "        if len(date[0])==4:\n",
    "            ans.append(date[0][:2])\n",
    "        else:\n",
    "            ans.append(\"0\"+date[0][0])\n",
    "        return '-'.join(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day,month,year=date.split()\n",
    "        li=[\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        dic={mon:id for id,mon in enumerate(li,1)}\n",
    "        return \"%s-%02d-%02d\" %(year,dic[month],int(day[:-2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date_li = date.split()\n",
    "        months_set = [\"\",\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        days_set = [\"\", \"1st\", \"2nd\", \"3rd\", \"4th\", \"5th\", \"6th\", \"7th\", \"8th\", \"9th\", \"10th\", \"11th\", \"12th\", \"13th\", \"14th\", \"15th\", \"16th\", \"17th\", \"18th\", \"19th\", \"20th\", \"21st\", \"22nd\", \"23rd\", \"24th\", \"25th\", \"26th\", \"27th\", \"28th\", \"29th\", \"30th\", \"31st\"]\n",
    "        year, month, day = date_li[-1], str(months_set.index(date_li[1])), str(days_set.index(date_li[0]))\n",
    "        day = '0' + day if len(day)==1 else day\n",
    "        month = '0' + month if len(month)==1 else month\n",
    "        return year + '-' + month + '-' + day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date = date.split(\" \")\n",
    "        \n",
    "        day = \"0\" + date[0][:1] if len(date[0]) == 3 else date[0][:2]\n",
    "        m = {\"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\", \"May\":\"05\", \"Jun\":\"06\",\"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "        mon = m[date[1]]\n",
    "        year = date[2]\n",
    "        return \"-\".join([year, mon, day])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "import re\n",
    "from datetime import datetime\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        segs = list(re.search(r'(\\d{1,2}).*?(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec).*?(\\d{4})', date, flags=re.I).groups())\n",
    "        segs[1] = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"].index(segs[1]) + 1\n",
    "        day, month, year = segs\n",
    "        return datetime(int(year), month, int(day)).strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        my_dict = {\"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\", \"May\":\"05\", \"Jun\":\"06\", \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "        date1 = date.split()\n",
    "        res = \"\"\n",
    "        res = res+date[-4:]+\"-\"+my_dict[date1[1]]+\"-\"\n",
    "        if date[1].isalpha():\n",
    "            date = '0'+date\n",
    "        for i in range(len(date)):\n",
    "            if date[i].isdigit():\n",
    "                res = res+date[i]\n",
    "            else:\n",
    "                break\n",
    "        return res\n",
    "        \n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        po = date.split(' ')\n",
    "        months = {}\n",
    "        moth = []\n",
    "        for i in range(1,32):\n",
    "            moth.append(i)\n",
    "        moth_2 =  [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        for a,b in zip(moth,moth_2):\n",
    "            months[b] = a\n",
    "        month = months[po[1]]   #月份\n",
    "        if len(str(month)) == 1:\n",
    "            month = '0' + str(month)\n",
    "        if len(po[0]) == 3:      #日\n",
    "            day = '0'+po[0][0]\n",
    "        if len(po[0]) == 4:\n",
    "            day = po[0][:2]\n",
    "        year = po[2]\n",
    "        ik = '{}-{}-{}'.format(year,month,day)\n",
    "        return ik"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day, mon, year = date.split()\n",
    "        mon_lst = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\n",
    "        mon_map = {mon:idx for idx, mon in enumerate(mon_lst, 1)}\n",
    "        return '%s-%02d-%02d' % (year, mon_map[mon], int(day[:-2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "import re\n",
    "from datetime import datetime\n",
    "\n",
    "months = (\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\")\n",
    "months_regex = '|'.join(months)\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        segs = re.search(rf'(\\d{{1,2}}).*?({months_regex}).*?(\\d{{4}})', date, flags=re.I).groups()\n",
    "        day, month, year = segs\n",
    "        month = months.index(month) + 1\n",
    "        return datetime(int(year), month, int(day)).strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day,month,year=date.split()\n",
    "        dic={\"Jan\":1, \"Feb\":2, \"Mar\":3, \"Apr\":4, \"May\":5, \"Jun\":6, \"Jul\":7, \"Aug\":8, \"Sep\":9, \"Oct\":10, \"Nov\":11, \"Dec\":12}\n",
    "        m=dic.get(month)\n",
    "        return \"%s-%02d-%02d\" %(year,m,int(day[:-2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        months = {\"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\",\n",
    "         \"May\":\"05\", \"Jun\":\"06\", \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "\n",
    "        pattern = '([0-9]{1,2})[a-z]{2}[ \\t]+(\\w{3})[ \\t]+(\\d{4})'\n",
    "        day = re.search(pattern,date).group(1)\n",
    "        if len(day) == 1:\n",
    "            day = '0' + day\n",
    "        month = re.search(pattern,date).group(2)\n",
    "        year = re.search(pattern,date).group(3)\n",
    "    \n",
    "        return year +\"-\"+ months[month] +\"-\"+ day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        months = {\"Jan\":\"01\", \"Feb\":\"02\", \"Mar\":\"03\", \"Apr\":\"04\",\n",
    "         \"May\":\"05\", \"Jun\":\"06\", \"Jul\":\"07\", \"Aug\":\"08\", \"Sep\":\"09\", \"Oct\":\"10\", \"Nov\":\"11\", \"Dec\":\"12\"}\n",
    "        pattern = '([0-9]{1,2})[a-z]{2}[ \\t]+(\\w{3})[ \\t]+(\\d{4})'\n",
    "        day = re.search(pattern,date).group(1)\n",
    "        if len(day) == 1:\n",
    "            day = '0' + day\n",
    "        month = re.search(pattern,date).group(2)\n",
    "        year = re.search(pattern,date).group(3)\n",
    "        return year +\"-\"+ months[month] +\"-\"+ day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        date_list = date.split(' ')\n",
    "        res = ''\n",
    "        d = {\"Jan\":'01', \"Feb\":'02', \"Mar\":'03', \"Apr\":'04', \"May\":'05', \"Jun\":'06', \"Jul\":'07', \"Aug\":'08', \"Sep\":'09', \"Oct\":'10', \"Nov\":'11', \"Dec\":'12'}\n",
    "        res += date_list[2]\n",
    "        res += '-'\n",
    "        res += d[date_list[1]]\n",
    "        res += '-'\n",
    "        t = date_list[0][:len(date_list[0])-2]\n",
    "        if len(t) == 1:\n",
    "            t = '0'+t\n",
    "        res += t\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        day, mon, year = date.split()\n",
    "        mon_lst = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        mon_map = {mon:idx for idx,mon in enumerate(mon_lst,1)}\n",
    "        return \"%s-%02d-%02d\" % (year, mon_map[mon], int(day[:-2]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        dd, mm, yy = date.split(\" \")\n",
    "        dd = \"\".join(w for w in dd if w.isnumeric())\n",
    "        lst = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"]\n",
    "        mm = str(lst.index(mm) + 1)\n",
    "        if len(dd) == 1:\n",
    "            dd = \"0\" + dd\n",
    "        if len(mm) == 1:\n",
    "            mm = \"0\" + mm\n",
    "        return f\"{yy}-{mm}-{dd}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        y = dict(zip((\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"),(1,2,3,4,5,6,7,8,9,10,11,12)))\n",
    "        x = date[0:2] if len(date) == 13 else \"0\"+date[0]\n",
    "        return f\"{date[-4:]}-{y[date[-8:-5]]:0>2d}-{x}\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "import re\n",
    "from datetime import datetime\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        segs = re.search(r'(\\d{1,2}).*?(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec).*?(\\d{4})', date, flags=re.I).groups()\n",
    "        day, month, year = segs\n",
    "        month = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"].index(month) + 1\n",
    "        return datetime(int(year), month, int(day)).strftime('%Y-%m-%d')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def reformatDate(self, date: str) -> str:\n",
    "        dic = {\"Jan\":\"01\", \n",
    "                \"Feb\":\"02\",\n",
    "                \"Mar\":\"03\",\n",
    "                \"Apr\":\"04\",\n",
    "                \"May\":\"05\",\n",
    "                \"Jun\":\"06\",\n",
    "                \"Jul\":\"07\",\n",
    "                \"Aug\":\"08\",\n",
    "                \"Sep\":\"09\",\n",
    "                \"Oct\":\"10\",\n",
    "                \"Nov\":\"11\",\n",
    "                \"Dec\":\"12\"}\n",
    "        date = date.split(\" \")\n",
    "        if int(date[0][:-2])<10:\n",
    "            day = \"0\"+ date[0][:-2]\n",
    "        else:\n",
    "            day = date[0][:-2]\n",
    "        return date[2]+\"-\"+dic[date[1]]+\"-\"+day"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
